﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RecruitStudents.Utility.Config
{
    public class GlobalHelper
    {
        // 程序的根目录
        public static string pathRoot = "";
        //照片显示路径
        public static string pathPhoto = "";
        //照片保存路径
        public static string pathSavePhoto = "";
        //是否记录日志
        public static bool IsLog = true;
        public static string URL = "";
        public static void SetConfig()
        {
            URL = ConfigurationManager.AppSettings["Url"].ToSafeString();
            try
            {
                pathRoot = System.Web.HttpContext.Current.Request.PhysicalApplicationPath;
            }
            catch
            {
                pathRoot = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath;
            }
            pathPhoto = ConfigurationManager.AppSettings["PhotoPath"].ToSafeString();
            pathSavePhoto = ConfigurationManager.AppSettings["SavePhotoPath"].ToSafeString();
            string _isLog = ConfigurationManager.AppSettings["IsLog"].ToSafeString();
            if (!_isLog.IsNullOrEmptyString())
            {
                IsLog = _isLog.ToSafeBool();
            }
            else
            {
                IsLog = true;
            }
        }
    }
}
